package com.tom.mybatis.executor;

import com.tom.mybatis.config.Configuration;

/**
 * @author : tom
 * @project: tom-mybatis
 * @date : 2018/11/7 15:00
 */
public class ExecutorFactory {

    private static  final  String SIMPLE="SIMPLE";
    private static  final  String CACHING="CACHING";

    public static  Executor DEFAULT(Configuration configuration){
        return get(SIMPLE,configuration);

    }

    public static Executor get(String key, Configuration configuration) {
        if(SIMPLE.equals(key)){
            return new SimpleExecutor(configuration);
        }
        if(CACHING.equals(key)){
            return new CachingExecutor(new SimpleExecutor(configuration));
        }
        throw  new RuntimeException("no executor found");
    }

    public enum ExecutorType {
        SIMPLE,CACHING
    }

}
